package com.xuxin.baby.adapter;

import android.widget.ImageView;

import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xuxin.baby.R;
import com.xuxin.baby.bean.ChildSmellyBean;
import com.xuxin.baby.glide.GlideApp;
import com.xuxin.baby.network.Retrofit;
import com.xuxin.baby.utils.BaseUtils;

import org.jetbrains.annotations.NotNull;

/**
 * Created by xu_xin
 * Created on 2020.08.04 0004
 * 记臭臭
 */
public class ChildSmellyAdapter extends BaseQuickAdapter<ChildSmellyBean.ResultBean.ItemsBean, BaseViewHolder> {

    public ChildSmellyAdapter() {
        super(R.layout.item_child_smelly);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, ChildSmellyBean.ResultBean.ItemsBean itemsBean) {
        String name = itemsBean.getShitColor() + "; " + itemsBean.getShitCharacter() + "; " + itemsBean.getShitQty() + "; " + itemsBean.getShitFreq() + "次/天";
        holder.setText(R.id.item_child_smelly_name, name);
        holder.setText(R.id.item_child_smelly_time, BaseUtils.getTime(itemsBean.getEventDate()));
        /**
         * 加载图片
         */
        RequestOptions options = new RequestOptions().transform(new CenterCrop(), new RoundedCorners(8));
        ImageView item_child_smelly_image = holder.getView(R.id.item_child_smelly_image);
        String smellyImage = Retrofit.image_url + itemsBean.getPic1();
        LogUtils.e("记臭臭_image = " + smellyImage);
        if (itemsBean.isShow()) {
            GlideApp.with(getContext()).load(smellyImage).placeholder(R.mipmap.img_smelly_hide).apply(options).into(item_child_smelly_image);
        } else {
            GlideApp.with(getContext()).load(R.mipmap.img_smelly_hide).placeholder(R.mipmap.img_smelly_hide).apply(options).into(item_child_smelly_image);
        }
    }
}